home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / OS / FWToolbx / Sources / PRWinPro.cpp < prev    next >
Encoding:
Text File  |  1996-08-16  |  5.9 KB  |  207 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                PRWinPro.h
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWODTYPS_H
  13. #include "FWODTyps.h"
  14. #endif
  15.  
  16. #ifndef PRWINPRO_H
  17. #include "PRWinPro.h"
  18. #endif
  19.  
  20. #ifndef FWODEXCE_H
  21. #include "FWODExce.h"
  22. #endif
  23.  
  24. #ifndef SLWINDOW_H
  25. #include "SLWindow.h"
  26. #endif
  27.  
  28. #ifndef FWRECT_H
  29. #include "FWRect.h"
  30. #endif
  31.  
  32. #ifndef FWFXMATH_H
  33. #include "FWFxMath.h"
  34. #endif
  35.  
  36. #ifndef FWSTRING_H
  37. #include "FWString.h"
  38. #endif
  39.  
  40. // ----- OpenDoc Utilities -----
  41.  
  42. #ifndef _STDTYPIO_
  43. #include "StdTypIO.h"
  44. #endif
  45.  
  46. #ifndef _STORUTIL_
  47. #include "StorUtil.h"
  48. #endif
  49.  
  50. // ----- OpenDoc Includes -----
  51.  
  52. #ifndef SOM_Module_OpenDoc_Errors_defined
  53. #include <ErrorDef.xh>
  54. #endif
  55.  
  56. #ifndef SOM_ODStorageUnit_xh
  57. #include <StorageU.xh>
  58. #endif
  59.  
  60. #ifndef SOM_ODDraft_xh
  61. #include <Draft.xh>
  62. #endif
  63.  
  64. #ifndef SOM_ODFrame_xh
  65. #include <Frame.xh>
  66. #endif
  67.  
  68. #ifndef SOM_Module_OpenDoc_StdTypes_defined
  69. #include <StdTypes.xh>
  70. #endif
  71.  
  72. #ifndef SOM_Module_OpenDoc_StdProps_defined
  73. #include <StdProps.xh>
  74. #endif
  75.  
  76. //========================================================================================
  77. //    Runtime Info
  78. //========================================================================================
  79.  
  80. #ifdef FW_BUILD_MAC
  81. #pragma segment fwwindow
  82. #endif
  83.  
  84. //========================================================================================
  85. //    WindowProperties API
  86. //========================================================================================
  87.  
  88. //----------------------------------------------------------------------------------------
  89. //    FW_PrivInitWindowProperties
  90. //----------------------------------------------------------------------------------------
  91.  
  92. FW_PlatformError SL_API FW_PrivInitWindowProperties(FW_SWindowProperties* windowProperties)
  93. {
  94.     // No try block necessary - Do not throw
  95. #ifdef FW_BUILD_MAC
  96.     FW_CPoint interiorSize(
  97.         FW_IntToFixed(FW_QDGlobals.screenBits.bounds.right - 64), 
  98.         FW_IntToFixed(FW_QDGlobals.screenBits.bounds.bottom - LMGetMBarHeight() - 4 - 4 - 20));
  99.     FW_CPoint position(FW_IntToFixed(4), FW_IntToFixed(LMGetMBarHeight() + 4 + 19));
  100.     FW_CRect rect(position.x, position.y, position.x + interiorSize.x, position.y + interiorSize.y);
  101.     windowProperties->fBoundsRect = rect;
  102.  
  103.     windowProperties->fMacTitle[0] = 0;
  104.     windowProperties->fMacProcID = FW_PrivMacStyleToProcId(FW_kDocumentWindow);
  105.     windowProperties->fMacHasCloseBox = TRUE;
  106.     windowProperties->fMacRefCon = 0;
  107. #endif
  108.  
  109. #ifdef FW_BUILD_WIN
  110.     FW_DEBUG_MESSAGE("Not Yet Implemented");
  111. #endif
  112.  
  113.     windowProperties->fWasVisible = TRUE;
  114.     windowProperties->fIsFloating = FALSE;
  115.     windowProperties->fIsRootWindow = TRUE;
  116.     windowProperties->fShouldShowLinks = FALSE;
  117.     windowProperties->fSourceFrame = NULL;
  118.     windowProperties->fIsResizable = TRUE;
  119.     
  120.     return FW_xNoError;
  121. }
  122.  
  123. //----------------------------------------------------------------------------------------
  124. //    FW_PrivReadWindowProperties
  125. //----------------------------------------------------------------------------------------
  126.  
  127. FW_Boolean SL_API FW_PrivReadWindowProperties(Environment* ev, FW_SWindowProperties* windowProperties, ODFrame* frame)
  128. {
  129.     FW_Boolean result = FALSE;
  130.         
  131.     FW_TRY
  132.     {
  133.         // ----- Initialize the property record -----
  134.         if (windowProperties->fSourceFrame)
  135.             windowProperties->fSourceFrame->Release(ev);
  136.         FW_PrivInitWindowProperties(windowProperties);
  137.         
  138.         // ----- read -----
  139.         ODStorageUnit* frameSU = frame->GetStorageUnit(ev);
  140.         ODStorageUnit* windowPropsSU = kODNULL;
  141.     
  142.         ODID id = ODGetStrongSURefProp(ev, frameSU, kODPropWindowProperties, kODStrongStorageUnitRef);
  143.         if (id == 0)
  144.             return FALSE;
  145.         
  146.     #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
  147.         windowPropsSU = frameSU->GetDraft(ev)->AcquireStorageUnit(ev,id);
  148.     #else
  149.         windowPropsSU = frameSU->GetDraft(ev)->GetStorageUnit(ev,id);
  150.     #endif
  151.     
  152.         if (windowPropsSU)
  153.         {
  154.             ODRect odRect;
  155.             ODGetRectProp(ev, windowPropsSU, kODPropWindowRect, kODRect, &odRect);
  156.             windowProperties->fBoundsRect = FW_CRect(odRect);
  157.             
  158.     #ifdef FW_BUILD_MAC
  159.             ODIText* iText = ODGetITextProp(ev, windowPropsSU, kODPropWindowTitle, kODMacIText, NULL);
  160.             if (iText)
  161.             {
  162.                 FW_CString string(iText);
  163.                 string.ExportPascal(windowProperties->fMacTitle);
  164.                 ::DisposeIText(iText);
  165.             }
  166.     
  167.             windowProperties->fMacProcID = ODGetSShortProp(ev, windowPropsSU, kODPropWindowProcID, kODSShort);
  168.             windowProperties->fMacHasCloseBox = ODGetBooleanProp(ev, windowPropsSU, kODPropWindowHasCloseBox, kODBoolean);
  169.             windowProperties->fMacRefCon = ODGetSLongProp(ev, windowPropsSU, kODPropWindowRefCon, kODSLong);
  170.     #endif
  171.     
  172.             windowProperties->fIsResizable = ODGetBooleanProp(ev, windowPropsSU, kODPropWindowIsResizable, kODBoolean);
  173.             windowProperties->fWasVisible = ODGetBooleanProp(ev, windowPropsSU, kODPropWindowIsVisible, kODBoolean);
  174.             windowProperties->fShouldShowLinks = ODGetBooleanProp(ev, windowPropsSU, kODPropShouldShowLinks, kODBoolean);
  175.             
  176.             windowProperties->fIsFloating = ODGetBooleanProp(ev, windowPropsSU, kODPropWindowIsFloating, kODBoolean);
  177.             windowProperties->fIsRootWindow = ODGetBooleanProp(ev, windowPropsSU, kODPropWindowIsRootWindow, kODBoolean);
  178.             
  179.             if (windowPropsSU->Exists(ev, kODPropSourceFrame, kODStrongStorageUnitRef, 0))
  180.             {
  181.                 ODID id = ODGetStrongSURefProp(ev, windowPropsSU, kODPropSourceFrame, kODStrongStorageUnitRef);
  182.     #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
  183.                 windowProperties->fSourceFrame = windowPropsSU->GetDraft(ev)->AcquireFrame(ev, id);
  184.     #else
  185.                 windowProperties->fSourceFrame = windowPropsSU->GetDraft(ev)->GetFrame(ev, id);
  186.     #endif
  187.             }
  188.     
  189.             windowPropsSU->Release(ev);
  190.             
  191.             result = TRUE;
  192.         }
  193.     }
  194.     FW_CATCH_BEGIN 
  195.     FW_CATCH_REFERENCE(FW_XException, exception)
  196.     {
  197.         FW_SetException(ev, exception);
  198.     }
  199.     FW_CATCH_EVERYTHING () 
  200.     {
  201.         FW_SetEvError(ev, kODErrUndefined);
  202.     }
  203.     FW_CATCH_END
  204.  
  205.     return result;
  206. }
  207.